package bite;
import java.util.*;
/**
 * Creared with IntelliJ IDEA.
 * Description:【求和】输入两个整数 n 和 m，从数列1，2，3.......n 中随意取几个数,使其和等于 m ,要求将其中所有的可能组合列出来
 * User:yxd
 * Date:2022-06-29
 * Time:14:42
 */
public class Day43_2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int m = input.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = i + 1;
        }
        List<List<Integer>> ret = new ArrayList<>();//存放结果
        List<Integer> list = new ArrayList<>();//过程
        boolean[] bool = new boolean[n];//标记矩阵
        DFS(nums,nums.length,0,ret,list,bool,m);
        for (List<Integer> a:ret) {
            for (int i = 0;i < a.size() - 1;i ++) {
                System.out.print(a.get(i) + " ");
            }
            System.out.println(a.get(a.size() - 1));
        }
    }
    public static void DFS(int[] nums, int len, int index, List<List<Integer>> ret, List<Integer> list, boolean[] bool, int m) {
        int count = 0;
        for (int x:list) {
            count += x;
        }
        if(count >= m){
            if(count == m){//满足条件
                ret.add(new ArrayList<>(list));
            }
            return;
        }
        for(int i = index;i < len;i ++){
            if(nums[i] > m){
                return;
            }
            if(!bool[i]){
                bool[i] = true;
                list.add(nums[i]);
                //递归
                DFS(nums,len,i + 1,ret,list,bool,m);
                bool[i] = false;
                //回溯
                list.remove(list.size() - 1);
            }
        }
    }

}
